# -*- coding: utf-8 -*-

from utils.operators.cluster_for_spark_sql_operator import SparkSqlOperator

from jms.dwd.oms.dwd_oms_order_dt import jms_dwd__dwd_oms_order_dt
# from jms.ods import jms_ods__tab_barscan_taking,jms_ods__tab_sitetakingmonitor
from jms.dwd.tab.dwd_tab_barscan_taking_base_dt import jms_dwd__dwd_tab_barscan_taking_base_dt
from jms.dwd.tab.dwd_tab_sitetakingmonitor_base_dt import jms_dwd__dwd_tab_sitetakingmonitor_base_dt
from jms.dim import jms_dim__dim_lmdm_sys_network_expand

jms_dm__dm_cn_export_vip_pdd_sum_dt = SparkSqlOperator(
    task_id='jms_dm__dm_cn_export_vip_pdd_sum_dt',
    pool_slots=3,
    task_concurrency=1,  # 如果任务不支持并发，则将 task_concurrency 设为 1
    name='jms_dm__dm_cn_export_vip_pdd_sum_dt_{{ execution_date | cst_ds }}',  # yarn 任务名称
    sql='jms/dm/dm_cn_export_vip_pdd_sum/execute.sql',
    driver_memory='2G' , 
    executor_memory='3G' , 
    executor_cores=4 , 
    num_executors=13 , 
    email=['lukunming@jtexpress.com','yl_bigdata@yl-scm.com'],
    conf={
        'spark.executor.memoryOverhead'             : '2G' , 
          'spark.core.connection.ack.wait.timeout': 3000,
          'spark.default.parallelism': 600,
          'spark.locality.wait': 60,
          'spark.driver.maxResultSize': 20,
          },
    hiveconf={'hive.exec.dynamic.partition'             : 'true',  # 动态分区
              'hive.exec.dynamic.partition.mode'        : 'nonstrict',
              'hive.exec.max.dynamic.partitions'        : 3,  # 每天生成 20 个分区
              'hive.exec.max.dynamic.partitions.pernode': 3,  # 每天生成 20 个分区
              },

    # java_class='com.yunlu.bigdata.jobs.export.ExportCollectPddDataNew',  # spark 主类
    # application='hdfs:///scheduler/jms/spark/lyx/ExportCollectPddDataNew/jobs-1.0-SNAPSHOT-jar-with-dependencies.jar',
    # spark jar 包
    # application_args=['{{ execution_date | date_add(1) | cst_ds }}'],
    # 参数dt 2020-10-26
)

# 设置依赖
jms_dm__dm_cn_export_vip_pdd_sum_dt << [
    jms_dim__dim_lmdm_sys_network_expand,
    jms_dwd__dwd_oms_order_dt,
    # jms_ods__tab_barscan_taking,
    # jms_ods__tab_sitetakingmonitor
jms_dwd__dwd_tab_barscan_taking_base_dt,
jms_dwd__dwd_tab_sitetakingmonitor_base_dt
]
